<template>
  <view class="order-status">
    <view class="title">
      <text>我的订单</text>
      <navigator url="/pages/order/list" class="view-all">
        查看全部
        <image class="right-icon" :src="rightIcon" mode="aspectFit"></image>
      </navigator>
    </view>
    <view class="status-list">
      <view class="status-item"
        v-for="(item, index) in orderStatus"
        :key="index"
        @click="navigateTo(item.url)"
      >
        <view class="icon-wrapper">
          <image class="status-icon" :src="item.iconPath" mode="aspectFit"></image>
          <text v-if="item.count > 0" class="badge">{{ item.count }}</text>
        </view>
        <text class="label">{{ item.label }}</text>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue'

// 图标路径变量
const rightIcon = '/static/icons/right.svg'

// 订单状态数据
const orderStatus = ref([
  {
    label: '待付款',
    icon: 'wallet',
    iconPath: '/static/icons/wallet.svg',
    url: '/pages/user/order-list?status=1',
    count: 0
  },
  {
    label: '待分享',
    icon: 'share',
    iconPath: '/static/icons/share.svg',
    url: '/pages/user/order-list?status=2',
    count: 0
  },
  {
    label: '待发货',
    icon: 'package',
    iconPath: '/static/icons/package.svg',
    url: '/pages/user/order-list?status=3',
    count: 0
  },
  {
    label: '待收货',
    icon: 'truck',
    iconPath: '/static/icons/truck.svg',
    url: '/pages/user/order-list?status=4',
    count: 0
  },
  {
    label: '待评价',
    icon: 'comment',
    iconPath: '/static/icons/comment.svg',
    url: '/pages/user/order-list?status=5',
    count: 0
  }
])

const navigateTo = (url) => {
  uni.navigateTo({ url })
}
</script>

<style lang="scss" scoped>
.order-status {
  background: #fff;
  padding: 30rpx;
  border-radius: 16rpx;

  .title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40rpx;
    padding: 0 10rpx;

    text {
      font-size: 32rpx;
      font-weight: bold;
    }

    .view-all {
      font-size: 26rpx;
      color: #666;
      display: flex;
      align-items: center;
      gap: 4rpx;

      .right-icon {
        width: 24rpx;
        height: 24rpx;
      }
    }
  }

  .status-list {
    display: flex;
    justify-content: space-between;
    padding: 0 10rpx;

    .status-item {
      text-align: center;
      flex: 1;

      .icon-wrapper {
        align-items: center;
        justify-content: center;
        margin-bottom: 16rpx;

        .status-icon {
          width: 56rpx;
          height: 56rpx;
        }

        .badge {
          position: absolute;
          top: -6rpx;
          right: -6rpx;
          background: #ff5722;
          color: #fff;
          font-size: 20rpx;
          min-width: 32rpx;
          height: 32rpx;
          padding: 0 8rpx;
          border-radius: 16rpx;
          line-height: 32rpx;
        }
      }

      .label {
        font-size: 26rpx;
        color: #333;
      }
    }
  }
}
</style>
